
global user "diegove"
global dirdata "C:\Users\\$user\Dropbox\CCT BJP\data"
global dir1  "$dirdata\Final data"
global dir2  "$dirdata\Results\graphs"
global dir3  "$dirdata\Results\"
cd "$dir3"

use "$dir1\pooled_hh.dta", clear
keep if tau>=-4  
g age=age_m if hhmale==0
replace age=age_p if hhmale==1
g spanish=spanish_m if hhmale==0
replace spanish=spanish_p if hhmale==1

g Post=tau>=0
egen w_hoursw_head=rowtotal(w_hoursw_p w_hoursw_m)
g work_head=w_hoursw_head>0
replace work_head=. if work_m==. & work_p==. 
egen w_ylabor_head=rowtotal(w_ylabor_p w_ylabor_m)

global covs "age spanish schooling hhmale  urban np nchild5  hhmale age_sac  c.age_sac#i.year c.np#i.year i.departamento#i.year i.year"



keep if tau>-5
local replace replace
foreach x in privado_hh nwork w_hoursw_t work_head w_hoursw_head work_m  w_hoursw_m work_p w_hoursw_p {
areg  `x'  tau_3 tau_4 tau_5 tau_7 tau_8 tau_9 tau_10 i.min_schooling  $covs [w=factor] if (min_schooling>=1 & min_schooling<9) , a(departamento) cluster(municipio) 
test (tau_3+tau_4+tau_5)=0
local F1=r(F)
local p1=r(p)
lincom (tau_3+tau_4+tau_5)
local est=r(estimate)
test  tau_3 tau_4 tau_5
local F2=r(F)
local p2=r(p)
outreg2 using "$dir3\PTable1Ftest", excel `replace'  keep(tau_1 tau_2 tau_3 tau_4 tau_5 tau_7 tau_8 tau_9 tau_10) less(0) nocons  bdec(3)  alpha(0.01, 0.05, 0.1) addtext(Estimate, `est', F-stat, `F1', P-val, `p1', F-stat, `F2', P-val, `p2')
local replace append
}

